<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>系统登陆</title>
<link href="${pageContext.request.contextPath }/css/mystyle1.css" rel="stylesheet" type="text/css">
 <script type="text/javascript" src="${pageContext.request.contextPath }/js/AjaxRequest.js"></script>
<script type="text/javascript"> 
function btn1(){
	var myselect1=document.getElementById("sel1");
	//var index=myselect.selectedIndex;
	//var id=myselect.options[index].value;
	var id1=myselect1.value;
	var myselect2=document.getElementById("sel2");
	var id2=myselect2.value;
	if(id1==""){
		alert("请选择培训期号!");
		return false;
	}
	else if(id2==""){
		alert("请选择学员!");
		return false;
	}
	var loader=new net.AjaxRequest("${pageContext.request.contextPath }/user/ajaxteach.action?noticeid="+id1+"&traineeid="+id2+"&nocache="+new Date().getTime(), deal_btn1, onerror, "GET");
 
  
}

function deal_btn1(){
	 document.getElementById("table").innerHTML=this.req.responseText;
}
 
 function onerror(){
	 alert("您的操作有误！");
 }
 
 

 
 
 function gettrain(seltrain){
 
	 var loader=new net.AjaxRequest("${pageContext.request.contextPath }/user/ajaxteasearch.action?noticeid="+seltrain+"&nocache="+new Date().getTime(), deal_gettrain, onerror, "GET");
	
 }
	 
 function deal_gettrain(){
		 
		 var result=this.req.responseText.split(";");
		 var tids=result[0].split(",");
		 var tnames=result[1].split(",");
		 document.getElementById("sel2").length=1;
	     for (var i  = 0; i  < tids.length; i ++) {
			document.getElementById("sel2").options[i+1]=new Option(tnames[i],tids[i]);
	    } 
 }
 
 function gettranandcour(seltrain){
	 
	 var loader=new net.AjaxRequest("${pageContext.request.contextPath }/user/ajaxteasearch.action?noticeid="+seltrain+"&nocache="+new Date().getTime(), deal_gettranandcour, onerror, "GET");
	 
 }
 
 function deal_gettranandcour(){
	 
	 var result=this.req.responseText.spilt("/");
	 var tids=result[0].split(",");;
	 var tnames=result[1].split(",");
	 var cids=result[2].split(",");
	 var cnames=result[3].split(",");
	 document.getElementById("sel4").length=1;
	 document.getElementById("sel5").length=1;
     for (var i  = 0; i  < tids.length; i ++) {
		document.getElementById("sel4").add(new  Option(tnames[i],tids[i]));
		}
     for (var j = 0; j < array.length; j++) {
    	 document.getElementById("sel5").add(new  Option(cnames[j],cids[j]));
	}
 }
 
 
 function btn2(){
	    var myselect3=document.getElementById("sel3");
	    var myselect4=document.getElementById("sel4");
	    var myselect5=document.getElementById("sel5");
		var value3=myselect3.value ;
		var value4=myselect4.value;
		var value5=myselect5.value;
		var text=document.getElementById("text");
		var value6=text.value;
		if(value3==""){
			alert("请选择培训期号!");
			return false;
		}
		else if(value4==""){
			alert("请选择学员!");
			return false;
		}
		else if(value5==""){
			alert("请选择课程!");
			return false;
		}
		else if(value6==""){
			alert("请输入成绩!");
			return false;
		}
	for (var i = 0; i < value6.length; i++) {
		var ch = value6.charAt(i);
		if( (ch < '0' || ch > '9') && ch != '-' ){
			 alert("只能输入数字!");
			text.focus();
			return false;
		}
		
	}

		var loader=new net.AjaxRequest("${pageContext.request.contextPath }/user/ajaxteachinsert.action?noticeid="+value3+"&traineeid="+value4+"&courseid="+value5+"&score="+value6+"&nocache="+new Date().getTime(), deal_btn2, onerror, "GET");
	 
 }
 
 function deal_btn2(){
	 alert(this.req.responseText);
 }

</script>
</head>
<body>
 

<div class="row" > 
  <div class="img">
   <img src="${user.img}" width="700" height="700" alt=""/>
   <div class="desc">头像 </div>
  </div>
  <div class="info">  
    <p>昵称:${user.name }</p>
    <p>性别:${user.sex}</p>
    <p> 地址:${user.address }</p>
  </div>
</div>
<div class="clearfix"></div>
 <hr>

 
<details>
<summary>成绩查询:</summary>
<select id="sel1" onchange="gettrain(this.value);">
 <option value="">培训期号</option>
 <c:forEach items="${noticeidmark }" var="id">
 <option value="${id }">${id }</option>
 </c:forEach>
</select>

<select id="sel2">
 <option value="">学员</option>
</select>

<button onclick="btn1();">查询</button>
<br><br>  
<div id="table">此处显示成绩内容</div>
</details>


<hr>


<details>
<summary>成绩录入:</summary>
<select id="sel3" onchange="gettranandcour(this.value);">
<option value="" selected="selected" >培训期号</option>
<c:forEach items="${noticeidsign }" var="id">
 <option value="${id }">${id }</option>
</c:forEach>
</select>

<select id="sel4">
<option value="" selected="selected">学员</option>
 
</select>

<select id="sel5">
<option  value="" selected="selected">课程</option>
 
</select>

<br>

<input type="text" id="text" value="请输入成绩"   style="width:auto" onfocus="this.value=''"  />
<button  onclick="btn2();">录入</button>
</details>
</body>
</html>



 
</body>
</html>